package CF;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
/**
 * 
 * @author shiv
 * Greedy sort by end in ascending and assign even for them first
 */
public class EventDates_45D {
	static BufferedReader br ;
	public static void main(String[] args) {
		PrintWriter pw = new PrintWriter(System.out);
		Scanner scn = new Scanner(System.in);
		class Tuple{
			int l, r, idx;
			Tuple(int ll, int rr, int i){
				l = ll;
				r = rr;
				idx = i;
			}
		}
		
		int size = scn.nextInt();
		Tuple[] tuples = new Tuple[size];
		int max = 0;
		for(int i=0; i<size; i++){
			tuples[i] = new Tuple(scn.nextInt(), scn.nextInt(), i);
			max= Math.max(max, tuples[i].r);
		}
		
		Arrays.sort(tuples, new Comparator<Tuple>() {

			@Override
			public int compare(Tuple o1, Tuple o2) {
				if(o1.r!=o2.r) return o1.r-o2.r;
				else if(o1.l != o2.l) return o1.l-o2.l;
				return 0;
			}
		});
		
		int[] res = new int[size];
		boolean [] isSel = new boolean[max+1];
		for(int i=0; i<size; i++){
			int cur = tuples[i].l;
			while(isSel[cur]){cur++;}
			res[tuples[i].idx] = cur;
			isSel[cur] = true; 
		}
		StringBuilder resStr = new StringBuilder();
		for(int i: res){
			resStr.append(i).append(" ");
		}
		System.out.println(resStr.toString());
		
	}
	
	
	

}
